package com.wssky.wxlogin;

import com.wssky.wxlogin.WXLoginRequest;
import static com.wssky.wxlogin.WXLoginConstans.getUserInfoByCode;

public class WXLogin {

    /**
     * "https://api.weixin.qq.com/sns/jscode2session?appid="+appid+"&secret="+secret+"&js_code="+code+"&grant_type=authorization_code";
     * @param wxLoginParam
     * @return
     * @throws Exception
     */
    public static String getUserInfoByCode(com.wssky.wxlogin.WXLoginParam wxLoginParam) throws Exception {
        String url = "";
        url = com.wssky.wxlogin.WXLoginConstans.apiUrl +
                getUserInfoByCode +
                "appid=" + wxLoginParam.getAppid() +
                "&secret=" + wxLoginParam.getSecret() +
                "&js_code=" + wxLoginParam.getCode() +
                "&grant_type=" + com.wssky.wxlogin.WXLoginConstans.grant_type_authorization_code;

        System.out.println("url: " + url);
        return null;
//        return WXLoginRequest.requestGetOne(url);
    }

    public static void main(String[] args) throws Exception {

        String appid = "wx862770dd69b7c1ba";
        String secret = "f1387cc581171c2bdd915f6c36f579f4";
        String code = "011LoOFa1ZwzSB0wyoFa1YgTAv2LoOF7";
        com.wssky.wxlogin.WXLoginParam wxLoginParam = new com.wssky.wxlogin.WXLoginParam();
        wxLoginParam.setAppid("wx862770dd69b7c1ba");
        wxLoginParam.setCode("061NS1ll2I6Eb84niZml2iTjlj0NS1lK");
        wxLoginParam.setSecret("f1387cc581171c2bdd915f6c36f579f4");
        System.out.println(getUserInfoByCode(wxLoginParam));//111.161.190.28

    }

}
